/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package BTL;
import java.io.*;
import java.util.*;
import javax.swing.*;
import static javax.swing.JOptionPane.*;

/**
 *
 * @author Le Trung Hieu
 */
public class MainGUI extends javax.swing.JFrame {

    /**
     * Creates new form MainGUI
     */
    ArrayList<Event> listEvent = new ArrayList<Event>(), listInput = new ArrayList<Event>();
    ArrayList<SingleRule> listSingleRule = new ArrayList<SingleRule>();
    ArrayList<AndRule> listAndRule = new ArrayList<AndRule>();
    ArrayList<OrRule> listOrRule = new ArrayList<OrRule>();
    
    AddRule formAddRule;
    ViewRule formViewRule;
    Guide formGuide;
    About formAbout;
    
    DieuTri dieuTri = new DieuTri();
    
    public MainGUI() {
        initComponents();
        if (!LoadFileEvent())
            System.exit(0);
        if (!LoadFileSingleRule())
            System.exit(0);
        if (!LoadFileAndRule())
            System.exit(0);
        if (!LoadFileOrRule())
            System.exit(0);
        
        formAddRule = new AddRule(this);
        formAddRule.setVisible(false);
        
        formViewRule = new ViewRule(this);
        formViewRule.setVisible(false);
        
        formGuide = new Guide();
        formGuide.setVisible(false);
        
        formAbout = new About();
        formAbout.setVisible(false);
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    public boolean LoadFileEvent()
    {
        FileReader fileReader;
        String stream;
        BufferedReader bufferReader;
        StringTokenizer tokenString;
        Event s;
        
        listEvent.clear();
        
        try
        {
            fileReader = new FileReader("src\\KB\\Event.txt");
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Không tìm thấy tệp sự kiện", "Lỗi khởi tạo", ERROR_MESSAGE);
            return false;
        }
        bufferReader = new BufferedReader(fileReader);
        
        do
        {
            try
            {
                stream = bufferReader.readLine();        
                if (stream == null)
                    break;
                if (stream.equals(""))
                    continue;
                tokenString = new StringTokenizer(stream, "|");
                s = new Event(Integer.parseInt(tokenString.nextToken()), 0.0f, tokenString.nextToken());
                listEvent.add(s);
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Lỗi đọc tệp sự kiện", "Lỗi khởi tạo", ERROR_MESSAGE);
                try
                {
                    bufferReader.close();
                }
                catch (Exception e1)
                {            
                }
                return false;
            }
        }
        while (true);
        try
        {
            bufferReader.close();
        }
        catch (Exception e)
        {            
        }
        return true;
    }
    public boolean LoadFileSingleRule()
    {
        FileReader fileReader;
        String stream;
        BufferedReader bufferReader;
        StringTokenizer tokenString;
        SingleRule ruleSingle;
        
        listSingleRule.clear();
        
        try
        {
            fileReader = new FileReader("src\\KB\\SingleRule.txt");
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Không tìm thấy tệp luật đơn", "Lỗi khởi tạo", ERROR_MESSAGE);
            return false;
        }
        bufferReader = new BufferedReader(fileReader);
        
        do
        {
            try
            {
                stream = bufferReader.readLine();        
                if (stream == null)
                    break;
                if (stream.equals(""))
                    continue;
                tokenString = new StringTokenizer(stream, "|");
                ruleSingle = new SingleRule(Integer.parseInt(tokenString.nextToken()), 
                        Integer.parseInt(tokenString.nextToken()), 
                        Float.parseFloat(tokenString.nextToken()));
                listSingleRule.add(ruleSingle);
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Lỗi đọc tệp luật đơn", "Lỗi khởi tạo", ERROR_MESSAGE);
                try
                {
                    bufferReader.close();
                }
                catch (Exception e1)
                {            
                }
                return false;
            }
        }
        while (true);
        try
        {
            bufferReader.close();
        }
        catch (Exception e)
        {            
        }
        return true;
    }
    public boolean LoadFileAndRule()
    {
        FileReader fileReader;
        String stream;
        BufferedReader bufferReader;
        StringTokenizer tokenString;
        AndRule ruleAnd;
        
        listAndRule.clear();
        
        try
        {
            fileReader = new FileReader("src\\KB\\AndRule.txt");
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Không tìm thấy tệp luật And", "Lỗi khởi tạo", ERROR_MESSAGE);
            return false;
        }
        bufferReader = new BufferedReader(fileReader);
        
        do
        {
            try
            {
                stream = bufferReader.readLine();            
                if (stream == null)
                    break;
                if (stream.equals(""))
                    continue;
                tokenString = new StringTokenizer(stream, "|");
                ruleAnd = new AndRule(Integer.parseInt(tokenString.nextToken()), 
                        Integer.parseInt(tokenString.nextToken()),
                         Integer.parseInt(tokenString.nextToken()),
                        Float.parseFloat(tokenString.nextToken()));
                listAndRule.add(ruleAnd);
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Lỗi đọc tệp luật And", "Lỗi khởi tạo", ERROR_MESSAGE);
                try
                {
                    bufferReader.close();
                }
                catch (Exception e1)
                {            
                }
                return false;
            }
        }
        while (true);
        try
        {
            bufferReader.close();
        }
        catch (Exception e)
        {            
        }        
        return true;
    }
    public boolean LoadFileOrRule()
    {
        FileReader fileReader;
        String stream;
        BufferedReader bufferReader;
        StringTokenizer tokenString;
        OrRule ruleOr;
        
        listOrRule.clear();
        
        try
        {
            fileReader = new FileReader("src\\KB\\OrRule.txt");
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, "Không tìm thấy tệp luật Or", "Lỗi khởi tạo", ERROR_MESSAGE);
            return false;
        }
        bufferReader = new BufferedReader(fileReader);
        
        do
        {
            try
            {
                stream = bufferReader.readLine();            
                if (stream == null)
                    break;
                if (stream.equals(""))
                    continue;
                tokenString = new StringTokenizer(stream, "|");
                ruleOr = new OrRule(Integer.parseInt(tokenString.nextToken()), 
                        Integer.parseInt(tokenString.nextToken()),
                         Integer.parseInt(tokenString.nextToken()),
                        Float.parseFloat(tokenString.nextToken()));
                listOrRule.add(ruleOr);
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(null, "Lỗi đọc tệp luật Or", "Lỗi khởi tạo", ERROR_MESSAGE);
                try
                {
                    bufferReader.close();
                }
                catch (Exception e1)
                {            
                }
                return false;
            }
        }
        while (true);
        try
        {
            bufferReader.close();
        }
        catch (Exception e)
        {            
        }       
        return true;
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        spAge = new javax.swing.JSpinner();
        spDegree = new javax.swing.JSpinner();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        spWeight = new javax.swing.JSpinner();
        spHigh = new javax.swing.JSpinner();
        jLabel7 = new javax.swing.JLabel();
        cbSex = new javax.swing.JComboBox();
        btExecute = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        cb03 = new javax.swing.JCheckBox();
        cb04 = new javax.swing.JCheckBox();
        cb01 = new javax.swing.JCheckBox();
        cb08 = new javax.swing.JCheckBox();
        cb05 = new javax.swing.JCheckBox();
        cb02 = new javax.swing.JCheckBox();
        cb06 = new javax.swing.JCheckBox();
        cb07 = new javax.swing.JCheckBox();
        cb12 = new javax.swing.JCheckBox();
        cb11 = new javax.swing.JCheckBox();
        cb17 = new javax.swing.JCheckBox();
        cb16 = new javax.swing.JCheckBox();
        cb13 = new javax.swing.JCheckBox();
        cb10 = new javax.swing.JCheckBox();
        cb09 = new javax.swing.JCheckBox();
        cb15 = new javax.swing.JCheckBox();
        cb18 = new javax.swing.JCheckBox();
        cb19 = new javax.swing.JCheckBox();
        cb20 = new javax.swing.JCheckBox();
        cb21 = new javax.swing.JCheckBox();
        cb23 = new javax.swing.JCheckBox();
        cb24 = new javax.swing.JCheckBox();
        cb22 = new javax.swing.JCheckBox();
        cb14 = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        spHeartCount = new javax.swing.JSpinner();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        cbAncol = new javax.swing.JComboBox();
        cbTobaco = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        btFormViewRule = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Hệ thống chẩn đoán bệnh thường gặp ở đường hô hấp");
        setBackground(new java.awt.Color(255, 255, 153));
        setForeground(new java.awt.Color(51, 255, 51));
        setResizable(false);

        jPanel2.setBackground(new java.awt.Color(102, 255, 102));

        spAge.setModel(new javax.swing.SpinnerNumberModel(0, 0, 200, 1));

        spDegree.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(37.0f), Float.valueOf(35.0f), Float.valueOf(42.0f), Float.valueOf(0.5f)));
        spDegree.setAutoscrolls(true);

        jLabel1.setText("Tuổi");

        jLabel2.setText("độ C");

        jLabel3.setText("Thân nhiệt");

        jLabel4.setText("tuổi");

        jLabel5.setText("jLabel1");

        jLabel6.setText("Độ cao");

        spWeight.setModel(new javax.swing.SpinnerNumberModel(0, 0, 300, 1));

        spHigh.setModel(new javax.swing.SpinnerNumberModel(0, 0, 300, 1));

        jLabel7.setText("Giới tính");

        cbSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Nam", "Nữ" }));
        cbSex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSexActionPerformed(evt);
            }
        });

        btExecute.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btExecute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/chan-doan.png"))); // NOI18N
        btExecute.setText("Chẩn đoán");
        btExecute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExecuteActionPerformed(evt);
            }
        });

        jLabel8.setText("cm");

        jLabel9.setText("kg");

        jLabel10.setText("Cân nặng");

        jPanel1.setBackground(new java.awt.Color(255, 255, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        cb03.setText("Ho kéo dài");

        cb04.setText("Ngạt mũi");

        cb01.setText("Ho");

        cb08.setText("Rát họng");
        cb08.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb08ActionPerformed(evt);
            }
        });

        cb05.setText("Khó thở");

        cb02.setText("Ho ra máu");
        cb02.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb02ActionPerformed(evt);
            }
        });

        cb06.setText("Khó nuốt");

        cb07.setText("Đau họng");

        cb12.setText("Đau nhức cơ bắp");

        cb11.setText("Thở khò khè");

        cb17.setText("Đau đầu");

        cb16.setText("Tức ngực");

        cb13.setText("Nhức đầu");

        cb10.setText("Thở gấp");

        cb09.setText("Bị đờm");

        cb15.setText("Đau ngực");

        cb18.setText("Sưng amiđan");

        cb19.setText("Đau mắt-trán");

        cb20.setText("Đau xương hàm");

        cb21.setText("Chảy nước mắt");

        cb23.setText("Mệt mỏi");

        cb24.setText("Cảm giác lạnh");

        cb22.setText("Nói khó");

        cb14.setText("Chóng mặt");

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel13.setText("Các biểu hiện của cơ thể");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cb01, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb02, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(cb03, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb04, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb05, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb06, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb07, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb08, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cb14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb12, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .addComponent(cb11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb09, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cb24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb17, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb18, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb19, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb20, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb21, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb22, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb23, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel13)
                .addGap(4, 4, 4)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb01)
                    .addComponent(cb09)
                    .addComponent(cb17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb02)
                    .addComponent(cb10)
                    .addComponent(cb18))
                .addGap(0, 0, 0)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb03)
                    .addComponent(cb11)
                    .addComponent(cb19))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb04)
                    .addComponent(cb12)
                    .addComponent(cb20))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb05)
                    .addComponent(cb13)
                    .addComponent(cb21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb06)
                    .addComponent(cb14)
                    .addComponent(cb22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb07)
                    .addComponent(cb15)
                    .addComponent(cb23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb08)
                    .addComponent(cb16, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cb24))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel11.setText("nhịp/phút");

        jLabel12.setText("Nhịp tim");

        spHeartCount.setModel(new javax.swing.SpinnerNumberModel(70, 1, 200, 1));

        jLabel14.setText("Rượu bia?");

        jLabel15.setText("Thuốc lá?");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel16.setText("Thông tin người cần chẩn đoán");

        cbAncol.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Nhiều", "Ít", "Không" }));
        cbAncol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAncolActionPerformed(evt);
            }
        });

        cbTobaco.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Nhiều", "Ít", "Không" }));
        cbTobaco.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTobacoActionPerformed(evt);
            }
        });

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/bs2.png"))); // NOI18N

        btFormViewRule.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btFormViewRule.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/them luat.png"))); // NOI18N
        btFormViewRule.setText("Xem luật");
        btFormViewRule.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFormViewRuleActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(spHigh, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(spWeight, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbSex, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(spHeartCount, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbAncol, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbTobaco, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addGap(492, 492, 492))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(48, 48, 48)
                                        .addComponent(btExecute)
                                        .addGap(0, 390, Short.MAX_VALUE))))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(1, 1, 1)
                                        .addComponent(spAge, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(spDegree, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(31, 31, 31)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btFormViewRule, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(jLabel5))
                            .addComponent(jLabel16)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addComponent(jLabel17)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(btFormViewRule, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(18, 18, 18)
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbAncol, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(13, 13, 13)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbTobaco, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(spAge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(spDegree, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(spHeartCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(spHigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(spWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbSex, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addComponent(btExecute)
                        .addGap(0, 17, Short.MAX_VALUE))))
        );

        jMenu1.setText("Hướng dẫn");
        jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu1MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Thông tin");
        jMenu2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu2MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void cb08ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb08ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cb08ActionPerformed
    private void Test()
    {
        Event s;
        SingleRule ruleSingle;
        OrRule ruleOr;
        AndRule ruleAnd;
        
        listEvent.clear();
        listSingleRule.clear();
        listAndRule.clear();
        listOrRule.clear();
        
        s = new Event(1, 0.9f);
        listEvent.add(s);
        s = new Event(2, 0.5f);
        listEvent.add(s);
        //s = new Event(3, 0.6f);
        //listEvent.add(s);
        
        ruleSingle = new SingleRule(1, 4, 0.8f);
        listSingleRule.add(ruleSingle);
        
        ruleSingle = new SingleRule(2, 3, 0.5f);
        listSingleRule.add(ruleSingle);
        
        ruleAnd = new AndRule(1, 3, 4, 0.9f);
        listAndRule.add(ruleAnd);
        
        ruleOr = new OrRule(2, 3, 4, 0.7f);
        listOrRule.add(ruleOr);
        
        Calculate cal = new Calculate(listEvent, listSingleRule, listAndRule, listOrRule);
        float dCF = cal.CalculateProbability(4);
        System.out.println(dCF);
    }
    
    private void GetAge()
    {
        int nAge;
        
        nAge = (int) spAge.getValue();        
        if (nAge <= 0) 
            return;       
        listInput.add(new Event(1201, 1.0f * (nAge <= 15 ? 1 : -0.1f)));
        listInput.add(new Event(1202, 1.0f * (nAge <= 70 ? 1 : -0.1f)));        
        listInput.add(new Event(1203, 1.0f * (nAge > 15 ? 1 : -0.1f)));
        listInput.add(new Event(1204, 1.0f * (nAge > 70 ? 1 : -0.1f)));        
    }
    
    private void GetDegree()
    {
        float fDegree;
        Event s;
        
        fDegree = (float) spDegree.getValue();
        
        if ((fDegree < 35) || (fDegree > 42))
            return;
        
        listInput.add(new Event(1101, 1.0f * (fDegree == 37f ? 1 : -0.1f)));
        listInput.add(new Event(1102, 1.0f * 
                ((fDegree >= 38f) && (fDegree <= 39) ? 1 : -0.1f)));
        listInput.add(new Event(1103, 1.0f * (fDegree > 39f ? 1 : -0.1f)));
        listInput.add(new Event(1104, 1.0f * 
                ((fDegree >= 36.5f) &&(fDegree <= 37.5f) ? 1 : -0.1f)));
        listInput.add(new Event(1105, 1.0f * (fDegree <= 36f ? 1 : -0.1f)));
    }
    
    private void GetHeartCount()
    {
        int nHeartCount;
        
        nHeartCount = (int) spHeartCount.getValue();
        if (nHeartCount <= 0)
            return;
        
        listInput.add(new Event(1301, 1.0f * 
                (((nHeartCount >= 65) && (nHeartCount <= 75)) ? 1 : -0.1f)));
        listInput.add(new Event(1302, 1.0f * (nHeartCount < 65 ? 1 : -0.1f)));
        listInput.add(new Event(1303, 1.0f * (nHeartCount > 75 ? 1 : -0.1f)));
    }
    
    private void GetBMI()
    {
        int nHigh, nWeight;
        float fHigh, fWeight, fBMI;
        
        nHigh =  (int) spHigh.getValue();
        nWeight = (int) spWeight.getValue();
        
        fHigh = ((float) nHigh) / 100;
        fWeight = (float) nWeight;
        if ((fHigh <= 0) ||(fWeight <= 0))
            return;
        fBMI = fWeight / (fHigh * fHigh);    
        
        listInput.add(new Event(1501, 1.0f * (fBMI < 18 ? 1 : -0.1f)));
        listInput.add(new Event(1502, 1.0f * 
                (((fBMI >= 18) && (fBMI <= 24)) ? 1 : -0.1f)));
        listInput.add(new Event(1503, 1.0f * (fBMI > 24 ? 1 : -0.1f)));
    }
    private void GetSex()
    {
        String sSex;
        
        sSex = (String) cbSex.getSelectedItem();
        if ((!sSex.equals("Nam")) && (!sSex.equals("Nữ")))
            return;
        listInput.add(new Event(1401, 1.0f * (sSex.equals("Nam") ? 1 : -0.1f)));
        listInput.add(new Event(1402, 1.0f * (sSex.equals("Nữ") ? 1 : -0.1f)));        
    }
    
    private void GetAncol()
    {
        String sAncol;
        
        sAncol = (String) cbAncol.getSelectedItem();
        if ((!sAncol.equals("Nhiều")) && (!sAncol.equals("Ít")) && (!sAncol.equals("Không")))
            return;
        listInput.add(new Event(1704, 1.0f * (sAncol.equals("Nhiều") ? 1 : -0.1f)));
        listInput.add(new Event(1705, 1.0f * (sAncol.equals("Ít") ? 1 : -0.1f)));  
        listInput.add(new Event(1706, 1.0f * (sAncol.equals("Không") ? 1 : -0.1f)));
    }
    
    private void GetTobaco()
    {
        String sTobaco;
        
        sTobaco = (String) cbTobaco.getSelectedItem();
        if ((!sTobaco.equals("Nhiều")) && (!sTobaco.equals("Ít")) && (!sTobaco.equals("Không")))
            return;
        listInput.add(new Event(1701, 1.0f * (sTobaco.equals("Nhiều") ? 1 : -0.1f)));
        listInput.add(new Event(1702, 1.0f * (sTobaco.equals("Ít") ? 1 : -0.1f)));  
        listInput.add(new Event(1703, 1.0f * (sTobaco.equals("Không") ? 1 : -0.1f)));
    }
    
    private void GetCheckBoxs()
    {
        listInput.add(new Event(1601, 1.0f * (cb01.isSelected() ? 1 : 0)));
        listInput.add(new Event(1602, 1.0f * (cb02.isSelected() ? 1 : 0)));
        listInput.add(new Event(1603, 1.0f * (cb03.isSelected() ? 1 : 0)));
        listInput.add(new Event(1604, 1.0f * (cb04.isSelected() ? 1 : 0)));
        listInput.add(new Event(1605, 1.0f * (cb05.isSelected() ? 1 : 0)));
        listInput.add(new Event(1606, 1.0f * (cb06.isSelected() ? 1 : 0)));
        listInput.add(new Event(1607, 1.0f * (cb07.isSelected() ? 1 : 0)));
        listInput.add(new Event(1608, 1.0f * (cb08.isSelected() ? 1 : 0)));
        listInput.add(new Event(1609, 1.0f * (cb09.isSelected() ? 1 : 0)));
        listInput.add(new Event(1610, 1.0f * (cb11.isSelected() ? 1 : 0)));
        listInput.add(new Event(1611, 1.0f * (cb11.isSelected() ? 1 : 0)));
        listInput.add(new Event(1612, 1.0f * (cb12.isSelected() ? 1 : 0)));
        listInput.add(new Event(1613, 1.0f * (cb13.isSelected() ? 1 : 0)));
        listInput.add(new Event(1614, 1.0f * (cb14.isSelected() ? 1 : 0)));
        listInput.add(new Event(1615, 1.0f * (cb15.isSelected() ? 1 : 0)));
        listInput.add(new Event(1616, 1.0f * (cb16.isSelected() ? 1 : 0)));
        listInput.add(new Event(1617, 1.0f * (cb17.isSelected() ? 1 : 0)));
        listInput.add(new Event(1618, 1.0f * (cb18.isSelected() ? 1 : 0)));
        listInput.add(new Event(1619, 1.0f * (cb19.isSelected() ? 1 : 0)));
        listInput.add(new Event(1620, 1.0f * (cb20.isSelected() ? 1 : 0)));
        listInput.add(new Event(1621, 1.0f * (cb21.isSelected() ? 1 : 0)));
        listInput.add(new Event(1622, 1.0f * (cb22.isSelected() ? 1 : 0)));
        listInput.add(new Event(1623, 1.0f * (cb23.isSelected() ? 1 : 0)));
        listInput.add(new Event(1624, 1.0f * (cb24.isSelected() ? 1 : 0)));
    }
    private void GetInput()
    {
        listInput.clear();
        GetAge();
        GetDegree();
        GetHeartCount();
        GetBMI();
        GetSex();
        GetCheckBoxs();
        GetAncol();
        GetTobaco();
    }
    private void btExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExecuteActionPerformed
        // TODO add your handling code here:        
        int nIndex;
        Event bestResult = new Event(0, 0f);
        Event tempEvent = new Event(0, 0f);
        GetInput();
        Calculate cal = new Calculate(listInput, listSingleRule, listAndRule, listOrRule);
        for (nIndex = 0; nIndex < listEvent.size(); nIndex++)
        {
            tempEvent = listEvent.get(nIndex);
            if ((tempEvent.nID < 5100) || (tempEvent.nID > 5199))
                continue;
            tempEvent.CF = cal.CalculateProbability(tempEvent.nID);
            if (tempEvent.CF > bestResult.CF)
            {
                bestResult.CF = tempEvent.CF;
                bestResult.nID = tempEvent.nID;
                bestResult.sDetail = tempEvent.sDetail;
            }
        }
        
        if (bestResult.CF <= 0)
        {
            JOptionPane.showMessageDialog(this, 
                    "Với thông tin đã nhập, hệ thống chưa đủ căn cứ để chẩn đoán bệnh về đường hô hấp.", 
                    "Kết quả", INFORMATION_MESSAGE);
        }
        else
        {
            JOptionPane.showMessageDialog(this, 
                    "Với thông tin đã nhập, hệ thống chẩn đoán: "
                    + bestResult.sDetail + ".\nĐộ chắc chắn: " 
                    + bestResult.CF + ".\nMã bệnh: " 
                    + bestResult.nID, 
                    "Kết quả", INFORMATION_MESSAGE);
            dieuTri.huongDanDieuTri(String.valueOf(bestResult.nID));
            dieuTri.setVisible(true);
            dieuTri.setLocationRelativeTo(null);
        }
    }//GEN-LAST:event_btExecuteActionPerformed

    private void cbSexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSexActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbSexActionPerformed

    private void cb02ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb02ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cb02ActionPerformed

    private void cbAncolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAncolActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbAncolActionPerformed

    private void cbTobacoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTobacoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbTobacoActionPerformed

    private void btFormViewRuleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFormViewRuleActionPerformed
        // TODO add your handling code here:
        formViewRule.setVisible(true);
        formViewRule.setFocusable(true);
    }//GEN-LAST:event_btFormViewRuleActionPerformed

    private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MouseClicked
        // TODO add your handling code here:
        formGuide.setVisible(true);
    }//GEN-LAST:event_jMenu1MouseClicked

    private void jMenu2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu2MouseClicked
        // TODO add your handling code here:
        formAbout.setVisible(true);
    }//GEN-LAST:event_jMenu2MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainGUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btExecute;
    private javax.swing.JButton btFormViewRule;
    private javax.swing.JCheckBox cb01;
    private javax.swing.JCheckBox cb02;
    private javax.swing.JCheckBox cb03;
    private javax.swing.JCheckBox cb04;
    private javax.swing.JCheckBox cb05;
    private javax.swing.JCheckBox cb06;
    private javax.swing.JCheckBox cb07;
    private javax.swing.JCheckBox cb08;
    private javax.swing.JCheckBox cb09;
    private javax.swing.JCheckBox cb10;
    private javax.swing.JCheckBox cb11;
    private javax.swing.JCheckBox cb12;
    private javax.swing.JCheckBox cb13;
    private javax.swing.JCheckBox cb14;
    private javax.swing.JCheckBox cb15;
    private javax.swing.JCheckBox cb16;
    private javax.swing.JCheckBox cb17;
    private javax.swing.JCheckBox cb18;
    private javax.swing.JCheckBox cb19;
    private javax.swing.JCheckBox cb20;
    private javax.swing.JCheckBox cb21;
    private javax.swing.JCheckBox cb22;
    private javax.swing.JCheckBox cb23;
    private javax.swing.JCheckBox cb24;
    private javax.swing.JComboBox cbAncol;
    private javax.swing.JComboBox cbSex;
    private javax.swing.JComboBox cbTobaco;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSpinner spAge;
    private javax.swing.JSpinner spDegree;
    private javax.swing.JSpinner spHeartCount;
    private javax.swing.JSpinner spHigh;
    private javax.swing.JSpinner spWeight;
    // End of variables declaration//GEN-END:variables
}
